package com.openbravo.pos.inventory;

import com.openbravo.basic.BasicException;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.model.Column;
import com.openbravo.data.model.Field;
import com.openbravo.data.model.PrimaryKey;
import com.openbravo.data.model.Row;
import com.openbravo.data.model.Table;
import com.openbravo.data.user.BrowsableEditableData;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.panels.AuxiliarFilter;
import com.openbravo.pos.panels.JPanelTable2;
import com.openbravo.pos.ticket.ProductInfoExt;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class AuxiliarPanel extends JPanelTable2
{
  private AuxiliarEditor editor;
  private AuxiliarFilter filter;

  protected void init()
  {
    this.filter = new AuxiliarFilter();
    this.filter.init(this.app);
    this.filter.addActionListener(new ReloadActionListener( ));
    this.row = new Row(new Field[] { new Field("ID", Datas.STRING, Formats.STRING), new Field("PRODUCT1", Datas.STRING, Formats.STRING), new Field("PRODUCT2", Datas.STRING, Formats.STRING), new Field(AppLocal.getIntString("label.prodref"), Datas.STRING, Formats.STRING, true, true, true), new Field(AppLocal.getIntString("label.prodbarcode"), Datas.STRING, Formats.STRING, false, true, true), new Field(AppLocal.getIntString("label.prodname"), Datas.STRING, Formats.STRING, true, true, true) });
    Table localTable = new Table("PRODUCTS_COM", new Column[] { new PrimaryKey("ID"), new Column("PRODUCT"), new Column("PRODUCT2") });
    this.lpr = this.row.getListProvider(this.app.getSession(), "SELECT COM.ID, COM.PRODUCT, COM.PRODUCT2, P.REFERENCE, P.CODE, P.NAME FROM PRODUCTS_COM COM, PRODUCTS P WHERE COM.PRODUCT2 = P.ID AND COM.PRODUCT = ?", this.filter);
    this.spr = this.row.getSaveProvider(this.app.getSession(), localTable);
    this.editor = new AuxiliarEditor(this.app, this.dirty);
  }

  public void activate()
    throws BasicException
  {
    this.filter.activate();
    startNavigation();
    reload(this.filter);
  }

  public Component getFilter()
  {
    return this.filter.getComponent();
  }

  public EditorRecord getEditor()
  {
    return this.editor;
  }

  public String getTitle()
  {
    return AppLocal.getIntString("Menu.Auxiliar");
  }

  private void reload(AuxiliarFilter paramAuxiliarFilter)
    throws BasicException
  {
    ProductInfoExt localProductInfoExt = paramAuxiliarFilter.getProductInfoExt();
    this.editor.setInsertProduct(localProductInfoExt);
    this.bd.setEditable(localProductInfoExt != null);
    this.bd.actionLoad();
  }

  private class ReloadActionListener
    implements ActionListener
  {
    private ReloadActionListener()
    {
    }

    public void actionPerformed(ActionEvent paramActionEvent)
    {
      try
      {
        AuxiliarPanel.this.reload((AuxiliarFilter)paramActionEvent.getSource());
      }
      catch (BasicException localBasicException)
      {
      }
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.inventory.AuxiliarPanel
 * JD-Core Version:    0.6.0
 */